x = input()  # input进制转换


def otk(x, K: int):
    s = str()
    while x > 0:
        r = x % K
        if r <= 9:
            s = str(r) + s
        else:
            s = chr(r + 1) + s
        x = x // K
    return s

# lis = list()
#
# for i in range(2, len(x) + 1):
#     v = otk(int(x), i)
#     middle = len(v) // 2
#     SA = sum(map(int, v[:middle + 1]))
#     SB = sum(map(int,v[middle:]))
#     lis.append(abs(SA - SB))
#
# print(lis)
